import 'iview/dist/styles/iview.css'
import 'babel-polyfill'

import vue from 'vue'
import iview from 'iview'
import Store from './store'
import Router from './router'
import vuexI18n from 'vuex-i18n';

import {
    sync
} from 'vuex-router-sync'

import VueSocketio from 'vue-socket.io';
import {
    AlertPlugin,
    ToastPlugin,
    ConfirmPlugin
} from 'vux'

vue.use(AlertPlugin)
vue.use(ToastPlugin)
vue.use(ConfirmPlugin)
vue.use(iview);

// Object.keys(vux).forEach((item) => {
//     vue.component(item, item);
// })

class app {
    constructor(config = {}) {
        this._store = new Store({
            modules: {
                i18n: vuexI18n.store
            }
        });
        vue.use(vuexI18n.plugin, this.store, {
            moduleName: 'i18n',
            onTranslationNotFound (locale, key) {
                console.warn(`i18n :: Key '${key}' not found for locale '${locale}'`);
            }});
        const translationsEn = {
            "content": "This is some {type} content"
        };
       
        vue.prototype.$i18n = function(localeType,translations){
            vue.i18n.add(localeType, translations);
        }
        // vue.i18n.add('en', translationsEn);
        vue.i18n.set('zh-CN');
        this._router = new Router();
        this._app = new vue({
            store: this.store,
            router: this.router
        });
        sync(this.store, this.router);
    }
    get conf() {
        return this._conf
    }

    get store() {
        return this._store
    }

    get router() {
        return this._router
    }

    get app() {
        return this._app
    }

}

export default app;